<template>
  <div class="tableview-root">
    <div class="filter-wrap">
      <div class="select" v-if="optionType===OptionType.Personal">
        <TextSelect
          v-for="item in Object.keys(selectOptionsDict)"
          :key="item"
          :options="selectOptionsDict[item]"
          :value="selectValueMap[item]"
          @change="(value) => onSelectChange(item, value)"
        />
      </div>
      <div class="select" v-else>{{optionType===OptionType.Recycle?'已删除活动':' '}}</div>
      <div class="search">
        <TextSearch placeholder="请输入活动标题" :value="searchVal" @search="onSearchText" />
        <TextButton
          v-for="item in Object.keys(buttonOptionsDict)"
          :key="item"
          @change="(value) => onButtonChange(item, value)"
          :option="buttonOptionsDict[item]"
          :icon="
            buttonOptionsDict[item].icons.find(
              (iconItem) => iconItem.effectValue === buttonValueMap[item]
            ).icon
          "
          link
        />

        <a class="filter-mode" @click="handleChangeView('grid')" v-if="viewModel==='list'">
          <SvgIcon class="x24" name="zu11729a1"></SvgIcon>
        </a>
        <a class="filter-mode" @click="handleChangeView('list')" v-else>
          <SvgIcon class="x24" name="zu11729"></SvgIcon>
        </a>
      </div>
    </div>
    <div class="list-wrapper" v-infinite-scroll="load" 
    infinite-scroll-delay="700">
      <el-table
        v-if="dataList.length>0&&viewModel==='list'"
        ref="multipleListTable"
        class="list-table"
        :data="dataList"
        empty-text="暂无数据"
        row-key="_id"
        header-row-class-name="tableview-header"
        row-class-name="tableview-row"
        cell-class-name="tableview-cell"
        style="width: 100%"
        v-loading="loading"
        @row-click="onRowClick"
      >
        <el-table-column column-key="space" width="10" />
        <el-table-column
          v-for="(field, index) in fieldList"
          :key="index"
          :label="field.title"
          :column-key="field.key"
          :width="field.width"
          :min-width="field.width || field.minWidth"
          class-name="link"
        >
          <template #default="scope">
            <template v-if="field.comp">
              <component
                :is="currentComponent(field.comp)"
                type="table"
                :value="unref(scope.row)"
              />
            </template>
            <template v-else-if="field.key === 'formName'">
              <div v-if="scope.row.formType===FormType.Dirs">
                <!-- <SvgIcon class="xfolder-table mr-step" name="folder"></SvgIcon> -->
                <img class="xfolder-table mr-step" src="@assets/images/folder.webp" alt="" />{{scope.row[field.key]}}
              </div>
              <span class="cell-span" v-else><img class="xfolder-table mr-step" src="@assets/images/fileform.webp" alt="" />{{ scope.row[field.key] }}</span>
            </template>
            <template v-else>
              <span class="cell-span">{{ scope.row[field.key] }}</span>
            </template>
          </template>
        </el-table-column>

        <el-table-column label="操作" :width="250" class-name="table-options" fixed="right">
          <template #default="scope">
            <ToolBar
              :data="scope.row"
              type="list"
              :tools="getToolConfig(scope.row)"
              :tool-width="60"
              @click="handleClick"
            />
          </template>
        </el-table-column>
      </el-table>

      <div class="tw-filegrid" v-if="dataList.length>0&&viewModel==='grid'">
        <div class="tw-filegrid-item" 
          v-for="(item, index) in dataList" 
          :key="index"
          @click="handleRowClick(item)">
          <div class="tw-filegrid-item-body" :class="{xfolder: item.formType===FormType.Dirs}">
            <div class="xfolderpanel" v-if="item.formType===FormType.Dirs">
              <img class="xfolder" src="@assets/images/folder.webp" alt="">
            </div>
            <div class="tw-filegrid-item-remark" v-else>
              <img class="xfolder-table mr-step" src="@assets/images/fileform.webp" alt="" />
              <span style="color: #333;" :title="item.formName">{{item.formName}}</span>
            </div>
            <div>
              <div class="folder-name" v-if="item.formType===FormType.Dirs">{{item.formName}}</div> 
              <div v-if="item.formType!==FormType.Dirs && !item.listConf">
                <el-skeleton animated >
                  <template #template>
                    <!-- <el-skeleton-item variant="image" style="width: 240px; height: 240px" /> -->
                    <div style="padding: 14px">
                      <el-skeleton-item variant="p" style="width: 100%; height: 12px;" />
                      <el-skeleton-item variant="p" style="width: 70%; height: 12px; margin-top: 10px;" />
                      <div
                        style="
                          display: flex;
                          align-items: center;
                          justify-items: space-between;
                        "
                      >
                        <el-skeleton-item variant="text" style="margin-right: 16px; height: 12px;" />
                        <el-skeleton-item variant="text" style="width: 40%; height: 12px;" />
                      </div>
                      <el-skeleton-item variant="p" style="width: 40%; height: 12px;margin-top: 5px;" />
                    </div>
                  </template>
                </el-skeleton>
              </div>
              <div class="container" v-if="item.formType!==FormType.Dirs && item.listConf">
                <template v-for="(ritm, ridx) in item.listConf.split(',')">
                  <p class="desc"  :key="ridx" v-if="ridx < 3">
                    <span v-html="ritm"></span>:
                  </p>
                </template>
              </div>
            </div>
          </div>
          <!-- <div class="tw-filegrid-item-name" style="font-size: 12px;">{{ item.formName }}</div> -->
          <div class="tw-filegrid-item-options">
            <ToolBar
              :data="item"
              limit="1"
              type="list"
              :tools="getToolConfig(item)"
              :tool-width="50"
              @click="handleClick"
            />
          </div>
        </div>
      </div>
    </div>

    <div v-if="dataList.length===0">
      <EmptyIndex :data="!searchVal ? (!hasAuth ? noAuthDataConfig[optionType] : noListDataConfig) : noSearchDataConfig" />
    </div>

    <ModifyDialog
      :type="modifyType"
      :visible="showModify"
      :question-info="questionInfo"
      @on-close-codify="onCloseModify"
    />

    <SpaceModify
      :type="modifyType"
      :visible="showDirModify"
      :spaceDetail="questionInfo"
      @on-close-codify="onCloseModify"
    />
    <PublishPage
     :formId="cooperId"
     :visible="formsPublishVisible"
     @on-close-codify="onClosePublish" />
  </div>
</template>

<script setup>
import { ref, computed, unref, watch } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { get, map } from 'lodash-es'

import { ElMessage, ElMessageBox } from 'element-plus'
import 'element-plus/theme-chalk/src/message.scss'
import 'element-plus/theme-chalk/src/message-box.scss'

import moment from 'moment'
// 引入中文
import 'moment/locale/zh-cn'
// 设置中文
moment.locale('zh-cn')

import EmptyIndex from '@/management/components/EmptyIndex.vue'
import { FormType, OptionType } from '@/management/utils/types/formsTypes'
import { CODE_MAP } from '@/management/api/eco/base'
import { QOP_MAP } from '@/management/utils/constant.ts'
import { del as deleteForm, copy as copyForm, publishForm, recover as recoverForm, foreverDel as foreverDelForm } from '@/management/api/dataform'
import { del as deleteCollect, save as saveCollect } from '@/management/api/dataform-collect'

import ModifyDialog from './ModifyDialog.vue'
import SpaceModify from './SpaceModify.vue'
import TagModule from './TagModule.vue'
import StateModule from './StateModule.vue'
import ToolBar from './ToolBar.vue'
import TextSearch from './TextSearch.vue'
import TextSelect from './TextSelect.vue'
import TextButton from './TextButton.vue'
// import CooperModify from './CooperModify.vue'
import PublishPage from '../../publish/PublishPage.vue'
// import { SurveyPermissions } from '@/management/utils/types/formsTypes'
import SvgIcon from '@common/SvgIcon/index.vue'

import {
  fieldConfig,
  noListDataConfig,
  noAuthDataConfig,
  noSearchDataConfig,
  selectOptionsDict,
  buttonOptionsDict
} from '@/management/config/formsConfig'

const store = useStore()
const router = useRouter()
const props = defineProps({
  loading: {
    type: Boolean,
    default: false
  },
  data: {
    type: Array,
    default: () => []
  },
  total: {
    type: Number,
    default: 0
  },
  hasAuth: {
    type: Boolean,
    default: false
  }
})
const emit = defineEmits(['reflush'])
const fields = ['formName', 'creatorName', 'lastModifyTime']

const showModify = ref(false)
const showDirModify = ref(false)
const formsPublishVisible = ref(false)
const modifyType = ref('')
const questionInfo = ref({})
const cooperId = ref('')

const viewModel = ref(store.state.viewModel)

const currentPage = ref(1)
const searchVal = computed(() => {
  return store.state.dataform.searchVal
})
const selectValueMap = computed(() => {
  return store.state.dataform.selectValueMap
})
const buttonValueMap = computed(() => {
  return store.state.dataform.buttonValueMap
})
const currentComponent = computed(() => {
  return (componentName) => {
    switch (componentName) {
      case 'TagModule':
        return TagModule
      case 'StateModule':
        return StateModule
      default:
        return null
    }
  }
})

const fieldList = computed(() => {
  return map(fields, (f) => {
    return get(fieldConfig, f, null)
  })
})

const data = computed(() => {
  return props.data
})
const total = computed(() => {
  return props.total
})
const dataList = computed(() => {
  return data.value.map((item) => {
    return {
      ...item
    }
  })
})

const filter = computed(() => {
  return [
    {
      comparator: '',
      condition: [
        {
          field: 'title',
          value: searchVal.value,
          comparator: '$regex'
        }
      ]
    },
    {
      comparator: '',
      condition: [
        {
          field: 'status',
          value: selectValueMap.value['status']
        }
      ]
    },
    {
      comparator: '',
      condition: [
        {
          field: 'OptionType',
          value: selectValueMap.value.OptionType
        }
      ]
    }
  ]
})
const order = computed(() => {
  const formatOrder = Object.entries(buttonValueMap.value)
    .filter(([, effectValue]) => effectValue)
    .reduce((prev, item) => {
      const [effectKey, effectValue] = item
      prev.push({ field: effectKey, value: effectValue })
      return prev
    }, [])
  return JSON.stringify(formatOrder)
})
const workSpaceId = computed(() => {
  return store.state.dataform.workSpaceId
})
const optionType = computed(() => {
  return store.state.dataform.optionType
})

const handleChangeView = (viewmodel) => {
  store.commit('setViewModel', viewmodel)
  viewModel.value = viewmodel
}
const onClosePublish = () => {
  cooperId.value = ''
  formsPublishVisible.value = false
}
const onReflush = async () => {
  const filterString = JSON.stringify(
    filter.value.filter((item) => {
      return item.condition[0].value
    })
  )
  let params = {
    curPage: currentPage.value,
    filter: filterString,
    order: order.value
  }
  if (workSpaceId.value) {
    params.workspaceId = workSpaceId.value
  }
  emit('reflush', params)
}

const getToolConfig = (row) => {
  let funcList = []
  const permissionsBtn = [
    {
      key: QOP_MAP.EDIT,
      label: '编辑'
    },
    {
      key: 'delete',
      label: '删除',
      icon: 'icon-shanchu'
    },
    {
      key: QOP_MAP.COPY,
      label: '复制',
      icon: 'icon-shanchu'
    },
    {
      key: 'analysis',
      label: '统计'
    },
    {
      key: 'release',
      label: '发布'
    },
    {
      key: 'collect',
      label: '收藏'
    }
  ]
  if (row.formType === FormType.Dirs) {
    funcList = funcList.concat([
      {
        key: QOP_MAP.EDIT,
        label: '编辑'
      },
      {
        key: 'delete',
        label: '删除',
        icon: 'icon-shanchu'
      }
    ])
  } else if (store.state.dataform.optionType === OptionType.Collect) {
    funcList = funcList.concat([
      {
        key: QOP_MAP.COPY,
        label: '复制'
      },
      {
        key: 'uncollect',
        label: '取消收藏',
        icon: 'icon-shanchu'
      }
    ])
  } else if (store.state.dataform.optionType === OptionType.Others) {
     funcList = funcList.concat([
      {
        key: QOP_MAP.COPY,
        label: '复制'
      },
      {
        key: 'collect',
        label: '收藏'
      }
    ])
  } else if (store.state.dataform.optionType === OptionType.Share) {
    funcList = funcList.concat([
      {
        key: QOP_MAP.EDIT,
        label: '编辑'
      },
      {
        key: QOP_MAP.COPY,
        label: '复制',
        icon: 'icon-shanchu'
      },
      {
        key: 'analysis',
        label: '统计'
      },
      {
        key: 'release',
        label: '发布'
      },
      {
        key: 'collect',
        label: '收藏'
      },
    ])
  } else if (store.state.dataform.optionType === OptionType.Personal) {
    funcList = permissionsBtn
  } else {
    if (row.status === '0') {
      // 删除状态
      funcList = funcList.concat([
        {
          key: 'recover',
          label: '恢复'
        },
        {
          key: 'delforever',
          label: '永久删除',
          icon: 'icon-shanchu'
        }
      ])
    } else if (row.creatorId === window.$app?.user?.userId) {
      funcList = permissionsBtn
    } else {
      funcList = [
        {
          key: QOP_MAP.COPY,
          label: '复制',
          icon: 'icon-shanchu'
        },
        {
          key: 'analysis',
          label: '统计'
        },
        {
          key: 'collect',
          label: '收藏'
        }
      ]
    }
  }
  const order = ['edit', 'copy', 'release', 'delete', 'collect', 'uncollect', 'recover', 'delforever', 'analysis']
  const result = funcList.sort((a, b) => order.indexOf(a.key) - order.indexOf(b.key))

  return result
}
const handleClick = (key, data) => {
  switch (key) {
    case QOP_MAP.EDIT:
      onModify(data, QOP_MAP.EDIT)
      return
    case QOP_MAP.COPY:
      onCopy(data, QOP_MAP.COPY)
      return
    case 'analysis':
      router.push({
        name: 'FormsPublishAnalysis',
        params: {
          id: data._id
        }
      })
      return
    case 'release':
      onPublish(data)
      return
    case 'delete':
      onDelete(data)
      return
    case 'recover':
      onRecover(data)
      return
    case 'delforever':
      onDelforever(data)
      return
    case 'collect':
      onCollect(data)
      return
    case 'uncollect':
      onUnCollect(data)
      return
    default:
      return
  }
}
const onDelete = async (row) => {
  try {
    await ElMessageBox.confirm('是否确认删除？', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
  } catch (error) {
    return
  }

  let res
    res = await deleteForm(row)
  
  if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
    ElMessage.success('删除成功')
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1
    onReflush()
  } else {
    ElMessage.error(res?.serverResult?.resultMessage || '删除失败')
  }
}
const onDelforever = async (row) => {
  try {
    await ElMessageBox.confirm('是否确认永久删除？', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
  } catch (error) {
    return
  }

  let res
    res = await foreverDelForm(row)
  
  if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
    ElMessage.success('删除成功')
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1
    onReflush()
  } else {
    ElMessage.error(res?.serverResult?.resultMessage || '删除失败')
  }
}
const onCollect = async (row) => {
  let res

  res = await saveCollect({formId: row._id, formType: row.formType})
  
  if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
    ElMessage.success('收藏成功')
  } else {
    ElMessage.error(res?.serverResult?.resultMessage || '收藏失败')
  }
}
const onUnCollect = async (row) => {
  let res

  res = await deleteCollect(row)
  
  if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
    ElMessage.success('取消收藏成功')
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1
    onReflush()
  } else {
    ElMessage.error(res?.serverResult?.resultMessage || '取消收藏失败')
  }
}
const onRecover = async (row) => {
  let res

  res = await recoverForm({formId: row._id, formType: row.formType})
  
  if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
    ElMessage.success('恢复成功')
  } else {
    ElMessage.error(res?.serverResult?.resultMessage || '恢复失败')
  }
}
// const handleCurrentChange = (current) => {
//   currentPage.value = current
//   onReflush()
// }
const onModify = (data, type = QOP_MAP.EDIT) => {
  if (data.formType === FormType.Dirs) {
    showDirModify.value = true
    modifyType.value = type
    questionInfo.value = data
  } else {
    router.push({
      name: 'FormsEditIndex',
      params: {
        id: data._id
      }
    })
  }
}
const onCopy = async (data, type = QOP_MAP.EDIT) => {
  // try {
    const res = await copyForm({
      formId: data._id,
      formType: data.formType
    })

    if (res?.serverResult?.resultCode === CODE_MAP.SUCCESS) {
      const { formId } = res.result
      router.push({
        name: 'FormsEditIndex',
        params: {
          id: formId
        },
        query: {
          tid: data._id
        }
      })
    } else {
      ElMessage.error(res?.serverResult?.resultMessage)
    }
  // } catch (err) {
  //   ElMessage.error(err)
  // }
}
const onCloseModify = (type) => {
  showModify.value = false
  showDirModify.value = false
  questionInfo.value = {}
  if (type === 'update') {
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1
    onReflush()
    fetchDirectoryList()
  }
}
const fetchDirectoryList = () => {
  store.dispatch('dataform/getDirectoryList')
}
const onRowClick = (row) => {
  if (row.formType === FormType.Dirs) {
    store.commit('dataform/changeOptionType', OptionType.Personal)
    store.commit('dataform/changeWorkSpace', row._id)
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1

    onReflush()
  } else {
    if (row.status === '1') {
      router.push({
        name: 'FormsEditIndex',
        params: {
          id: row._id
        }
      })
    } else {
      router.push({
        name: 'FormsPublishPage',
        params: {
          id: row._id
        }
      })
    }
  }
}
const handleRowClick = (row) => {
  if (row.formType === FormType.Dirs) {
    store.commit('dataform/changeOptionType', '1')
    store.commit('dataform/changeWorkSpace', row._id)
    store.commit('dataform/setFormsTotal', 0)
    store.commit('dataform/setFormsHasMore', true)
    currentPage.value = 1

    onReflush()
  } else {
    if (row.status === '1') {
      router.push({
        name: 'FormsEditIndex',
        params: {
          id: row._id
        }
      })
    } else {
      router.push({
        name: 'FormsPublishPage',
        params: {
          id: row._id
        }
      })
    }
  }
}
const onSearchText = (e) => {
  store.commit('dataform/setSearchVal', e)
  currentPage.value = 1
  onReflush()
}
const onSelectChange = (selectKey, selectValue) => {
  store.commit('dataform/changeSelectValueMap', { key: selectKey, value: selectValue })
  // selectValueMap.value[selectKey] = selectValue
  store.commit('dataform/setFormsTotal', 0)
  store.commit('dataform/setFormsHasMore', true)
  currentPage.value = 1
  onReflush()
}
const onButtonChange = (effectKey, effectValue) => {
  store.commit('dataform/reserButtonValueMap')
  store.commit('dataform/changeButtonValueMap', { key: effectKey, value: effectValue })
  store.commit('dataform/setFormsTotal', 0)
  currentPage.value = 1
  store.commit('dataform/setFormsHasMore', true)
  onReflush()
}

const onPublish = async (row) => {
  if (row.status === '1') {
    const publishRes = await publishForm({ formId: row._id })
    if (publishRes?.serverResult?.resultCode === '200') {
      ElMessage.success('发布成功')
      // router.push({
      //   name: 'FormsPublishPage',
      //   params: {
      //     id: row._id
      //   }
      // })
      cooperId.value = row._id
      formsPublishVisible.value = true
    } else {
      ElMessage.error(`发布失败 ${publishRes?.serverResult?.resultMessage}`)
    }
    
  } else {
    // router.push({
    //   name: 'FormsPublishPage',
    //   params: {
    //     id: row._id
    //   }
    // })
    cooperId.value = row._id
    formsPublishVisible.value = true
  }
}

const busy = ref(false);
const load = async () => {
  if (busy.value) {
    return
  }
  busy.value = true

  // if (!store.state.dataform.formsTotal <= 1) {
  //   currentPage.value = 1
  // }
  if (store.state.dataform.formsHasMore) {
    setTimeout(async () => {
      currentPage.value += 1
      await onReflush().then(() => {
        busy.value = false;
      })
    }, 1000)
  } else {
    setTimeout( () => {
      busy.value = true
    }, 1000)
  }
}
watch(() => props.total, (newQuery, oldQuery) => {
  currentPage.value = 1
  load()
}, {
  immediate: true
})
</script>

<style lang="scss" scoped>
.tableview-root {
  .filter-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    .select {
      display: flex;
    }
    .search {
      display: flex;
    }

    .filter-mode {
      padding: 6px 0;
      margin-left: 10px;
      cursor: pointer;
    }
  }
  .list-wrapper {
    
    background: #fff;
    .list-table {
      min-height: 620px;

      img.xfolder-table {
        height: 16px;
        line-height: 23px;
      }
    }
  }

  .list-pagination {
    margin-top: 20px;
    :deep(.el-pagination) {
      display: flex;
      justify-content: flex-end;
    }
  }
  :deep(.el-table__header) {
    .tableview-header .el-table__cell {
      .cell {
        height: 24px;
        color: #4a4c5b;
        font-size: 14px;
      }
    }
  }
  :deep(.tableview-row) {
    .tableview-cell {
      padding: 5px 0;
      &.link {
        cursor: pointer;
      }
      .cell .cell-span {
        font-size: 14px;
      }
    }
  }
}
.el-select-dropdown__wrap {
  background: #eee;
}
.el-select-dropdown__item.hover {
  background: #fff;
}

.tw-filegrid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.tw-filegrid-item {
  width: calc(12.5% - 9px);
  margin-right: 10px;
  margin-bottom: 20px;
  background: #FFFFFF;
  position: relative;

  .container {
      display: flex;
      flex-direction: column;
      margin-top: 15px;
      padding: 10px;
      height: 75px;
      background: #FFFFFF;
      border-radius: 4px 4px 4px 4px;
      // border: 1px solid #E8E8E8;
      overflow: hidden;
      color: #999;
      font-size: 12px;
      line-height: 22px;
      .desc {
        width: 100%;
        height: 28px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        position: relative;
        padding-left: 12px;
      }
      .desc::before {
        left: 0px;
        top: 8px;
        content: ' ';
        display: inline-block;
        width: 4px;
        height: 4px;
        background: #e6e8eb;
        border-radius: 50%;
        position: absolute;
      }
    }
}

.tw-filegrid-item:nth-child(8n) {
  margin-right: 0px;
}
.tw-filegrid-item-options {
  position: absolute;
  right: 0;
  top: 0;
  visibility: hidden;
}
.tw-filegrid-item:hover .tw-filegrid-item-options {
  visibility: visible;
}
.tw-filegrid-item-body {
  box-shadow: 0px 6px 16px 1px rgba(0,0,0,0.06);
  border-radius: 6px 6px 6px 6px;
  border: 1px solid #ECECEC;
  padding: 10px 10px 5px 10px;
  height: 146px;

  &.xfolder {
    box-shadow: none;
    border: none;
    // padding-top: 10px;
  }

  .xfolderpanel {
    text-align: center;
  }
  .folder-name {
    text-align: center;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
  }
}
.tw-filegrid-item-name {
  margin-top: 10px;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tw-filegrid-item-remark {
  margin-top: 5px;
  color: #999;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  > span {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 1699px) {
  .tw-filegrid-item {
    width: calc(12.5% - 9px);
  }

  .tw-filegrid-item:nth-child(8n) {
    margin-right: 0px;
  }
}

@media (max-width: 1599px) {
  .tw-filegrid-item {
    width: calc(14.3% - 9px);
  }

  .tw-filegrid-item:nth-child(8n) {
    margin-right: 10px;
  }
  .tw-filegrid-item:nth-child(7n) {
    margin-right: 0px;
  }
}

@media (max-width: 1499px) {
  .tw-filegrid-item {
    width: calc(16.67% - 9px);
  }

  .tw-filegrid-item:nth-child(7n) {
    margin-right: 10px;
  }
  .tw-filegrid-item:nth-child(6n) {
    margin-right: 0px;
  }
}

@media (max-width: 1399px) {
  .tw-filegrid-item {
    width: calc(20% - 8px);
  }

  .tw-filegrid-item:nth-child(6n) {
    margin-right: 10px;
  }
  .tw-filegrid-item:nth-child(5n) {
    margin-right: 0px;
  }
}

</style>
